# hide & show
execute unless entity @e[tag=rmr.rotten_pillager_captain] run return run bossbar set rmr:rotten_pillager_captain visible false
execute if entity @e[tag=rmr.rotten_pillager_captain] run bossbar set rmr:rotten_pillager_captain visible true

# everyone see it
bossbar set rmr:rotten_pillager_captain players @a

# change name
execute unless score @n[tag=rmr.rotten_pillager_captain] rmr.entity.rotten_pillager_captain.hell_skill_counter matches 1.. run bossbar set rmr:rotten_pillager_captain name [{"translate": "rmr.entity.rotten_pillager_captain","color": "red"}]
execute if score @n[tag=rmr.rotten_pillager_captain] rmr.entity.rotten_pillager_captain.hell_skill_counter matches 1.. run bossbar set rmr:rotten_pillager_captain name [{"translate": "rmr.entity.rotten_pillager_captain","color": "red"}, " ", {"translate": "rmr.state.invincible","color": "white"}]

# health sync
execute store result bossbar rmr:rotten_pillager_captain max run attribute @n[tag=rmr.rotten_pillager_captain] generic.max_health get
execute store result bossbar rmr:rotten_pillager_captain value run data get entity @n[tag=rmr.rotten_pillager_captain] Health
